/*============================================================================
 PROJECT: Kleii
 FILE:    MKAssetPickerController.m
 AUTHOR:  Khoai Nguyen Minh
 DATE:    12/21/13
 =============================================================================*/

/*============================================================================
 IMPORT
 =============================================================================*/
#import "MKAssetPickerController.h"
#import "MKAssetGroupPickerViewController.h"
#import "UIViewController+TopViewController.h"

/*============================================================================
 PRIVATE MACRO
 =============================================================================*/
/*============================================================================
 PRIVATE INTERFACE
 =============================================================================*/

@interface MKAssetPickerController ()

@end

@implementation MKAssetPickerController

+ (MKAssetPickerController *)assetPickerController {
    @autoreleasepool {
        MKAssetGroupPickerViewController *groupPickerViewController = [[MKAssetGroupPickerViewController alloc] init];
        MKAssetPickerController *picker = [[MKAssetPickerController alloc] initWithRootViewController:groupPickerViewController];
        return picker;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)pickerAssetsType:(MKAssetType)assetType resultBlock:(void(^)(NSMutableArray *assets, NSError *error))resultBlock {
    self.callback = resultBlock;
    self.assetType = assetType;
    
    /* show picker allbum here */
    UIViewController *topViewController = [UIViewController topViewController];
    if(topViewController) {
        if(SupportiOS7) {
            [topViewController presentViewController:self animated:YES completion:^{
                
            }];
        } else {
            [topViewController presentModalViewController:self animated:YES];
        }
    }
}

@end
